/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package FrameUser;

import Database.CheckConnection;
import Model.UserPenerima;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;

/**
 *
 * @author admin
 */
public class UserProfile extends JFrame{
    private JTextArea labelText;
    private JButton buttonOk;

    public UserProfile() throws SQLException, Exception {
        this.setTitle("Profile User");
        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        this.setBounds(460, 270, 220, 220);
        this.setLayout(null);
        
        Connection con = CheckConnection.open("jdbc:oracle:thin:@localhost:1521:XE", "hr", "12345");
        Statement stat = con.createStatement();
        String sql = "select * from USER_PENERIMA where ID_USER in (select DATA from CACHE)";
        ResultSet hasil = stat.executeQuery(sql);
        UserPenerima user = new UserPenerima();
        while (hasil.next()) {
            user.setIdUserPenerima(hasil.getString("ID_USER"));
            user.setNamaUserPenerima(hasil.getString("NAMA_USER"));
        }
        
        labelText = new JTextArea();
        labelText.setBounds(25, 20, 140, 110);
        labelText.setBackground(null);
        labelText.setEditable(false);
        labelText.setText("                 PROFILE : \n\nNama    :    "+user.getNamaUserPenerima()+"\n\nID           :    "+user.getIdUserPenerima());
        this.add(labelText);

        buttonOk = new JButton("OK");
        buttonOk.setBounds(68, 135, 70, 30);
        this.add(buttonOk);
        buttonOk.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                setVisible(false);
            }
        });

    }
    
}
